package com.heima.comment.controller;

import com.heima.comment.service.CommentService;
import com.heima.model.comment.dtos.CommentDto;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {
    @Autowired
    CommentService commentService;

    @PostMapping("/save")
    public ResponseResult saveComment(@RequestBody CommentDto commentDto){
        log.info("存评论");
        return commentService.saveComment(commentDto);
    }

    @PostMapping("/load")
    public PageResponseResult loadCommentList(@RequestBody CommentDto commentDto){
        log.info("查评论列表");
        return commentService.loadCommentList(commentDto);
    }

    @PostMapping("/like")
    public ResponseResult setLike(@RequestBody CommentDto commentDto){
        log.info("点赞");
        return commentService.setLike(commentDto);
    }
}
